home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / option.exe / TOPTION.H < prev    next >
C/C++ Source or Header  |  1992-10-25  |  5KB  |  164 lines

  1. /* ---------------------------------------------------------------------- */
  2. /*      class TOptionViewer                                               */
  3. /*                                                                        */
  4. /*      Palette layout                                                    */
  5. /*        1 = Active                                                      */
  6. /*        2 = Inactive                                                    */
  7. /*        3 = Focused                                                     */
  8. /*        4 = Selected                                                    */
  9. /*        5 = Divider                                                     */
  10. /* ---------------------------------------------------------------------- */
  11.  
  12. #if defined( Uses_TOptionViewer ) && !defined( __TOptionViewer )
  13. #define __TOptionViewer
  14.  
  15. class far TRect;
  16. class far TScrollBar;
  17. class far TCollection;
  18.  
  19. class TOptionViewer : public TListViewer
  20. {
  21.  
  22. public:
  23.  
  24.     TOptionViewer( const TRect& bounds,
  25.                    TScrollBar *aHScrollBar,
  26.                    TScrollBar *aVScrollBar,
  27.                    TCollection *aList
  28.                   );
  29.  
  30.     virtual TPalette& getPalette() const;
  31.     virtual void getText( char *dest, short item, short maxLen );
  32.     virtual void handleEvent( TEvent& event );
  33.     int optionWidth();
  34.  
  35.     virtual TCollection *list();
  36.     virtual void newList( TCollection *aList );
  37.  
  38. protected:
  39.  
  40.     TCollection *items;
  41.  
  42. };
  43.  
  44. #endif  // Uses_TOptionViewer
  45.  
  46. #if defined( Uses_TOptionWindow ) && !defined( __TOptionWindow )
  47. #define __TOptionWindow
  48.  
  49. class far TListViewer;
  50. class far TRect;
  51. class far TWindow;
  52. class far TInputLine;
  53. class far TCollection;
  54.  
  55. class TOptionInit
  56. {
  57.  
  58. public:
  59.  
  60.     TOptionInit( TListViewer *(*cListViewer)( TRect, TWindow *,
  61.                TCollection * ) );
  62.  
  63. protected:
  64.  
  65.     TListViewer *(*createListViewer)( TRect, TWindow *, TCollection * );
  66.  
  67. };
  68.  
  69. /* ---------------------------------------------------------------------- */
  70. /*      TOptionWindow                                                     */
  71. /*                                                                        */
  72. /*      Palette layout                                                    */
  73. /*        1 = Frame passive                                               */
  74. /*        2 = Frame active                                                */
  75. /*        3 = Frame icon                                                  */
  76. /*        4 = ScrollBar page area                                         */
  77. /*        5 = ScrollBar controls                                          */
  78. /*        6 = HistoryViewer normal text                                   */
  79. /*        7 = HistoryViewer selected text                                 */
  80. /* ---------------------------------------------------------------------- */
  81.  
  82. class TOptionWindow : public TWindow, public virtual TOptionInit
  83. {
  84.  
  85. public:
  86.  
  87.     TOptionWindow( const TRect& bounds, TCollection *aList );
  88.  
  89.     virtual TPalette& getPalette() const;
  90.     virtual void getSelection( char *dest );
  91.     static TListViewer *initViewer( TRect, TWindow *, TCollection * );
  92.  
  93.     virtual TCollection *list();
  94.     virtual void newList( TCollection *aList );
  95.  
  96. protected:
  97.  
  98.     TListViewer *viewer;
  99. };
  100.  
  101. #endif  // Uses_TOptionWindow
  102.  
  103. #if defined( Uses_TOption ) && !defined( __TOption )
  104. #define __TOption
  105.  
  106. class far TRect;
  107. class far TInputLine;
  108. class far TEvent;
  109. class far TOptionWindow;
  110. class far TCollection;
  111.  
  112. class TOption : public TView
  113. {
  114.  
  115. public:
  116.  
  117.     TOption( const TRect& bounds, TInputLine *aLink, TCollection *aList );
  118.  
  119.     virtual void draw();
  120.     virtual TPalette& getPalette() const;
  121.     virtual void handleEvent( TEvent& event );
  122.     virtual TOptionWindow *initOptionWindow( const TRect& bounds );
  123.     virtual void shutDown();
  124.  
  125.     virtual TCollection *list();
  126.     virtual void newList( TCollection *aList );
  127. protected:
  128.  
  129.     TInputLine *link;
  130.     TCollection *items;
  131.  
  132. private:
  133.  
  134.     static const char * near icon;
  135.  
  136.     virtual const char *streamableName() const
  137.         { return name; }
  138.  
  139. protected:
  140.  
  141.     TOption( StreamableInit );
  142.     virtual void write( opstream& );
  143.     virtual void *read( ipstream& );
  144.  
  145. public:
  146.  
  147.     static const char * const near name;
  148.     static TStreamable *build();
  149.  
  150. };
  151.  
  152. inline ipstream& operator >> ( ipstream& is, TOption& cl )
  153.     { return is >> (TStreamable&)cl; }
  154. inline ipstream& operator >> ( ipstream& is, TOption*& cl )
  155.     { return is >> (void *&)cl; }
  156.  
  157. inline opstream& operator << ( opstream& os, TOption& cl )
  158.     { return os << (TStreamable&)cl; }
  159. inline opstream& operator << ( opstream& os, TOption* cl )
  160.     { return os << (TStreamable *)cl; }
  161.  
  162. #endif  // Uses_TOption
  163.  
  164.